
cmake_minimum_required(VERSION 3.0)
project(mdk-examples  VERSION 0.0.0)

if(POLICY CMP0063) # visibility. since 3.3
  cmake_policy(SET CMP0063 NEW)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


if(NOT WIN32 AND NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/local/include)
  include_directories(/usr/local/include)
  link_directories(/usr/local/lib)
  list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include)
  list(APPEND CMAKE_REQUIRED_LIBRARIES -L/usr/local/lib)
endif()
include_directories(${EXTRA_INCLUDE})
#link_directories(${EXTRA_LIB_DIRS_FLAG}) # why will append -L.../examples and become invalid -L..../examples-L....external...?
foreach(LFLAG ${EXTRA_LIB_DIRS_FLAG})
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}")
endforeach()
#list(APPEND CMAKE_REQUIRED_INCLUDES ${EXTRA_INCLUDE})
#list(APPEND CMAKE_REQUIRED_LIBRARIES ${EXTRA_LIB_DIRS_FLAG})
if(WIN32)
  set(APPTYPE WIN32) # /subsystem:windows
endif()
if(MSVC)# AND NOT CMAKE_CXX_SIMULATE_ID MATCHES MSVC) # link.exe, lld>=8.0
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -entry:mainCRTStartup")
endif()

include(CheckLibraryExists)

if(NOT BUILD_MDK)
#list(APPEND CMAKE_PREFIX_PATH sdk/lib/cmake/mdk)
  find_package(mdk REQUIRED)
endif()

add_subdirectory(GLFW)
add_subdirectory(Native)
add_subdirectory(SDL)